<?php
/**
 * @description: 个人设置
 * @author     : Geomen
 * @time       : 2019/1/31 11:38
 */


namespace App\Http\Controllers;


use Illuminate\Http\Request;

class ProfileController extends Controller
{
    /**
     * 个人设置
     *
     * @param Request $request
     *
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function index(Request $request)
    {
        if ($request->isMethod('post')){
            $info = $request->user();
            $info->nickname = e($request->input('nickname'));
            if (filled($request->input('password'))){
                $info->password = bcrypt($request->input('password'));
            }
            if ($info->isDirty()){
                $info->save();
            }
            return redirect()->back()->with('success','个人设置修改成功');
        }
        return view('profile.index');
    }
}